package com.ajoclass.ft.steps;

import com.ajoclass.ft.tools.GetClient;
import com.ajoclass.ft.tools.MyAssert;
import com.jayway.restassured.response.Response;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;

/**
 * Created by ajo
 */
/*@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration // 不加此注解，bean会注入不进去
@SpringBootTest // 不加此注解会找不到bean*/
public class CommonSteps {
    Response response = null;
    //加个等待容器启动完成的step

    @When("^I send a GET request to \"(.*?)\"$")
    public void getRequest(String path) {
        response = GetClient.get(path);
    }


    @Then("^the response status should be \"(\\d{3})\"$")
    public void assertStatusCode(int statusCode) {
        Object jsonResponse = response.getStatusCode();
        MyAssert.assertEquals(jsonResponse, statusCode);
    }
}
